package com.itheima.作业.第六题;

//定义游泳接口:
interface Swim{
    //行为:游泳方法
    void swimming();
}

//定义动物类
public abstract class Animal {
    //属性:年龄
    private int age;

    public Animal() {
    }

    public Animal(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //行为:喝水,吃东西【吃什么不确定】
    public void drink(){
        System.out.println("喝水");
    }
    public abstract void eat();
}

//定义狗类
class Dog extends Animal implements Swim{

    public Dog() {
    }

    public Dog(int age) {
        super(age);
    }

    @Override
    public void swimming() {
        System.out.println("狗会狗刨游泳");
    }

    @Override
    public void eat() {
        System.out.println("狗啃骨头");
    }
}

//定义羊类
class Sheep extends Animal{

    public Sheep() {
    }

    public Sheep(int age) {
        super(age);
    }

    @Override
    public void eat() {
        System.out.println("羊啃草");
    }
}

//定义青蛙类
class Frog extends Animal implements Swim{

    public Frog() {
    }

    public Frog(int age) {
        super(age);
    }

    @Override
    public void eat() {
        System.out.println("青蛙吃小虫");
    }

    @Override
    public void swimming() {
        System.out.println("青蛙会蛙泳");
    }
}

//定义饲养员类
class AnimalOperator extends Animal{
    public AnimalOperator() {
    }

    public AnimalOperator(int age) {
        super(age);
    }

    //行为:饲养动物
    public void useAnimal(Animal animal){
        //先给动物喝水
        animal.drink();
        //再指挥动物吃饭
        animal.eat();

        //有游泳方法也需进行测试
        if (animal instanceof Dog){
            Dog d = (Dog)animal;
            d.swimming();
        }
        if (animal instanceof Frog){
            Frog frog = (Frog)animal;
            frog.swimming();
        }

    }

    @Override
    public void eat() {
        System.out.println("饲养员吃小动物");
    }
}
